﻿#ifndef SUBMITPRODUCTWIDGET_H
#define SUBMITPRODUCTWIDGET_H

#include <QDialog>
#include "product.h"
#include "productservice.h"

namespace Ui {
class SubmitProductWidget;
}

class SubmitProductWidget : public QDialog
{
    Q_OBJECT

public:
    enum SubmitWidgetType{
        NewProductWidget=0,
        UpdateProductWidget=1
    };
    Q_ENUM(SubmitWidgetType)

    explicit SubmitProductWidget(QWidget *parent = nullptr);
    ~SubmitProductWidget();
    //设置窗口类型 0：新商品 1：编辑商品
    void setWidgetType(SubmitWidgetType widgetType);

    void initWithProduct(Product *product);

    void showWithTargetProduct(Product *product);

    void setDirectory(QStringList primaryDirectoryList, QList<QStringList> secondaryDirectoryList);

    void setCurrentDirectory(QString primaryDirectory, QString secondaryDirectory);

    void showAndClear();

    void clear();

private slots:
    void on_pushButtonCancel_clicked();

    void on_pushButtonSubmit_clicked();

    void on_comboBoxPrimaryDirectory_currentIndexChanged(int index);

    void on_pushButtonDelete_clicked();

private:
    Ui::SubmitProductWidget *ui;

    SubmitWidgetType widgetType;
    ProductService productService;
    Product *product;

    QStringList primaryDirectoryList;
    QList<QStringList> secondaryDirectoryList;
};

#endif // SUBMITPRODUCTWIDGET_H
